package com.itheima.stock.job;

import com.itheima.stock.service.StockTimerTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定义股票相关数据的定时任务
 *
 * @author laofang
 */
@Component
public class StockJob {

    @Autowired
    private StockTimerTaskService stockTimerTaskService;

    @XxlJob("hema_job_test")
    public void jobTest() {
        System.out.println("jobTest run.....");
    }

    /**
     * 定时采集A股大盘数据
     * 建议：针对不同的股票数据，定义不同的采集任务，解耦，方便维护
     */
    @XxlJob("getInnerMarketInfo")
    public void getStockInfos() {
        stockTimerTaskService.getInnerMarketInfo();
    }

    /**
     * 定时采集各股数据
     */
    @XxlJob("getStockRtIndex")
    public void getStockRtIndex() {
        stockTimerTaskService.getStockRtIndex();
    }

    /**
     * 板块定时任务
     */
    @XxlJob("getStockBlockInfoTask")
    public void getStockBlockInfoTask() {
        stockTimerTaskService.getStockSectorRtIndex();
    }

    /**
     * 采集国外大盘
     */
    @XxlJob("getOuterMarketInfo")
    public void getOuterMarketInfo() {
        stockTimerTaskService.getOuterMarketInfo();
    }
}